package com.homework.proxy;

import com.homework.proxy.model.ExecuteCodeRequest;
import com.homework.proxy.model.ExecuteCodeResponse;

/**
 * @Author : Zan
 * @Create : 2024/6/16 15:02
 * @ClassName : CodeSandBoxProxy
 * @Description : 代码沙箱代理类(增强) - 代理类
 */
public class CodeSandBoxProxy implements CodeSandBox {

    private final CodeSandBox codeSandBox;

    public CodeSandBoxProxy(CodeSandBox codeSandBox) {
        this.codeSandBox = codeSandBox;
    }

    /**
     * 增强方法
     *
     * @param executeCodeRequest
     * @return
     */
    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        System.out.println("代码沙箱请求信息：" + executeCodeRequest.toString());
        ExecuteCodeResponse executeCodeResponse = codeSandBox.executeCode(executeCodeRequest);
        System.out.println("代码沙箱返回信息：" + executeCodeResponse.toString());
        return executeCodeResponse;
    }
}
